const http = require("http");
const fs = require("fs");

//  request请求,,,response响应
var server = http.createServer(function (req,res) {
	//req.url=>"/index.html"
	//读取+>"./www'+req.url
	//"./www"+req.url
	let file_name = "./www"+req.url;

	//读文件
	fs.readFile(file_name,function (err,data) {
		if(err){
			res.write("404");
		}else{
			res.write(data);
		}

		res.end();
	});

}).listen(8888);

//监听